package com.ryskoo.customer.vendordiscounts.repository;

import com.ryskoo.customer.vendordiscounts.domain.VendorDiscountsPO;
import com.ryskoo.framework.core.bean.QueryConditionEnum;
import com.ryskoo.framework.core.bean.QueryMessageDTO;
import com.ryskoo.framework.core.repository.BasicJPAImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class VendorDiscountsJPAImpl extends BasicJPAImpl<VendorDiscountsPO> implements IVendorDiscountsRepository {

    @Override
    public VendorDiscountsPO getByVendorUuid(String vendorUuid) {
        QueryMessageDTO qm = new QueryMessageDTO();
        qm.addCondition("vendorUuid", QueryConditionEnum.EQ.name(), vendorUuid);
        List<VendorDiscountsPO> list = this.queryByCondition(qm, false);
        if(CollectionUtils.isNotEmpty(list)){
            return list.get(0);
        }
        return null;
    }
}
